/*
 * 有关所有认证的审核状态
 *
 * */
import api from '../../api'

const state = {
  // 4种审核状态: 0等待审核，1审核中，2审核成功，3审核失败
  userAuditInfo: {},
  enterpriseAuditInfo: {}
}

const actions = {
  async getUserAuditInfo({commit}) {
    const res = await api.authentication.reqUserAuditInfo()
    if (res.code === 200) {
      const result = res.data
      commit('set_user_audit_info', {result})
      return Promise.resolve(result)
    }
  },

  clearUserAuditInfo({commit}) {
    commit('clear_user_audit_info')
  }
}
const mutations = {
  set_user_audit_info(state, {result}) {
    state.userAuditInfo = result
  },
  clear_user_audit_info(state) {
    state.userAuditInfo = {}
  }
}

export default {
  state,
  mutations,
  actions
}
